package chapter04.Example31;

import chapter04.Example30.Example30;

public class Example31 {
    public static void main(String[] args) {
        //定义try...catch语句用于捕获异常
        try{
            int insult = divide(4,-2);
            System.out.println(result);
        }catch (DivideByMinusException e){
            System.out.println(e.getMessage());
        }
    }
    //
    public static int divide(int x,int y)throws DivideByMinusException{
        if (y<0){
            throw new DivideByMinusException("除数是负数");
        }
        int result = x/y;
        return result;
    }
}
